package com.qf.springboot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * swagger配置文件, 项目启动就立即自动加载此类
 * */
@Configuration
public class SwaggerConfig {

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApiInfo())
                .select()
                //指定swagger扫描的controller的包路径
                .apis(RequestHandlerSelectors.basePackage("com.qf.springboot.user.controller"))
                .build();
    }

    private ApiInfo getApiInfo() {

        return new ApiInfoBuilder()
                .contact(new Contact("周考项目","http://www.baidu.com","15142527179@163.com"))
                .title("springboot项目")
                .version("0.0.1")
                .description("springboot项目的接口文档,使用swagger自动生成的")
                .build();
    }
}



























